﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("你好!我是汤锐妍");
            Console.WriteLine("请输入下限数字:");
            int lower = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入上限数字:");
            int upper = int.Parse(Console.ReadLine());

            Console.WriteLine($"在{lower}和{upper}之间的素数为:");

            int count = 0; // 用于计数，控制每行输出10个

            for (int num = lower; num <= upper; num++)
            {
                if (IsPrime(num))
                {
                    Console.Write(num + "\t");
                    count++;

                    if (count % 10 == 0) // 每10个换行
                    {
                        Console.WriteLine();
                    }
                }
            }

            if (count % 10 != 0) // 如果最后一行不足10个，也换行
            {
                Console.WriteLine();
            }
            Console.ReadLine();
        }
        // 判断是否为素数的辅助方法
        static bool IsPrime(int number)
        {
            if (number <= 1)
            {
                return false;
            }

            for (int i = 2; i <= Math.Sqrt(number); i++)
            {
                if (number % i == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}
